#!/usr/bin/perl
#creatlist.pl
#creates file list
#usage: perl createlist.pl -sdir FILEDIRECTORY [-h]
#WAVEFILEDIRECTORY: the directory which  contains the corpus wave files
#requieres sed

#Version: 1.0
#@author: Igor Jauk

use FindBin qw($Bin);
use lib "$Bin/../libs";
use config;
my $USAGE = "perl createlist.pl -sdir FILEDIRECTORY [-h] \n{requires sed. if not available install it (e.g. in Debian systems execute: \"sudo apt-get install sed\")}";

main();

sub main {
	my $cl = config->new(\@ARGV);
	if ($cl->optionflag("-h")) {
		print $USAGE."\n";
		exit;
	}
	
	my $sedcheck = qx(sed --version);
	if (!$sedcheck) {
		die "error: sed not installed.\n$USAGE\n";
	} else {
		print $sedcheck."\n";
	}
	
	my $wdir = $cl->optionarg("-sdir");	

	die "error: WAVEDIRDIRECTORY not specified.\nusage: $USAGE\n" if (!$cl->optionflag("-sdir"));
	
	qx(ls -1 $wdir | sed 's/\\(.*\\)\\..*/\\1/' > filelist);
	print "Filelist created. Exiting.\n";
}